package controller

import (
	"github.com/gin-gonic/gin"
	"cookbook-go/service"
)

type ElasticController struct {
	service *service.ElasticService
}

func InitElasticController(url string) *ElasticController {
	return &ElasticController{
		service: service.InitElasticService(url),
	}
}

func (it *ElasticController) GetLatestByPage(c *gin.Context) {
	bytes := it.service.GetLatestByPage(c)
	c.Data(200, "application/json", bytes)
}

func (it *ElasticController) GetHotestByPage(c *gin.Context) {
	bytes := it.service.GetHotestByPage(c)
	c.Data(200, "application/json", bytes)
}

func (it *ElasticController) GetCoursels(c *gin.Context) {
	bytes := it.service.GetCoursels(c)
	c.Data(200, "application/json", bytes)
}

func (it *ElasticController) GetByCategory(c *gin.Context) {
	bytes := it.service.GetByCategory(c)
	c.Data(200, "application/json", bytes)
}

func (it *ElasticController) SearchByKeyword(c *gin.Context) {
	bytes := it.service.SearchByKeyword(c)
	c.Data(200, "application/json", bytes)
}

func (it *ElasticController) SpecialSearch(c *gin.Context) {
	bytes := it.service.SpecialSearch(c)
	c.Data(200, "application/json", bytes)
}

func (it *ElasticController) WordAnalyze(c *gin.Context) {
	bytes := it.service.WordAnalyze(c)
	c.Data(200, "application/json", bytes)
}

func (it *ElasticController) ProxyQuery(c *gin.Context) {
	bytes := it.service.ProxyQuery(c)
	c.Data(200, "application/json", bytes)
}

func (it *ElasticController) GetOneById(c *gin.Context) {
	bytes := it.service.GetOneById(c)
	c.Data(200, "application/json", bytes)
}
